package com.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.javabean.Order;
import com.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class OrderController {
    @Autowired
    OrderService orderService;

    @RequestMapping("/orders/findAll")
    public String findAll(HttpServletRequest request, @RequestParam(value = "page",defaultValue = "1") int page,@RequestParam(value = "page",defaultValue = "5") int limit){
        PageHelper.startPage(1,5);//分页处理器，起始页为1，每页数据为5
        List<Order> all=orderService.findAll();
        request.setAttribute("all",all);
        PageInfo<Order> pageInfo=new PageInfo<>(all);
        request.setAttribute("pageInfo",pageInfo);
        return "orders/orders-list";
    }
}
